#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <string.h>
int main()
{
	char line[100];
	char *temp;
	char *word[10];
	int c;
	pid_t pid;
	while(1)
	{
		printf("> ");
		int num=1;
		fgets(line,sizeof(line),stdin);
		line[strlen(line)-1]='\0';
		temp=strtok(line," ");
		word[0]=temp;
		while(temp!=NULL)
		{
			temp=strtok(NULL," ");
			word[num]=temp;
			num++;
		}
		word[num]=NULL;
		pid =fork();
		if(pid==-1)
		{
			perror("can not open a precedure!");
			exit(1);
		}
		else if(pid==0)
		{
			execvp(word[0],word);
			exit(0);
		}
		else
		{
			wait(NULL);
		}
		if(strcmp(word[0],"exit")==0)
			exit(0);
	}
	return 0;
}
